﻿using System;

namespace FscNET.Apm
{
    /// <summary>
    /// This class is used when throwing an Exception to indicate 
    /// that an operation is being discarded but no EndXxx method 
    /// was specified and so resources are being leaked.
    /// </summary>
    public sealed class NoEndMethodCalled : ExceptionArgs
    {
        private readonly AsyncEnumerator m_ae;
        private readonly IAsyncResult m_ar;

        /// <summary>Returns the AsyncEnumerator object associated with this exception.</summary>
        public AsyncEnumerator AsyncEnumerator { get { return m_ae; } }

        /// <summary>Returns the IAsyncResult object associated with this exception.</summary>
        public IAsyncResult AsyncResult { get { return m_ar; } }

        internal NoEndMethodCalled(AsyncEnumerator ae, IAsyncResult ar)
        {
            m_ae = ae;
            m_ar = ar;
        }
    }
}
